class Todo
{
    String name
    String note
    Date createDate
    Date startDate
    Date dueDate
    Date completedDate
    Date lastModifiedDate
    String priority
    String status = "Started"
    User owner
    Categories category
    Keyword keywords
    
    static belongsTo = [User, Categories]
    static hasMany = [keywords:Keyword]


    static mapping =
    {
        table 'todo_tbl'
        columns
        {
            name column: 'name_str'
            note column: 'note_str'
            //indeksy
            name index: 'Name_idx'
            createDate index: 'Name_Create_Date_Idx'
        }
    }

    static constraints = 
    {
        name(blank:false)
        createDate()
        priority()
        status()
        note(maxSize:1000, nullable:true)
        completedDate(nullable:true)
        dueDate(nullabel:true)
        startDate(nullable:true,
            validator :
            {
                if(it?.compareTo(new Date()) < 0)
                {
                    return false
                }
                else
                {
                    return true
                }
            }
        )
    }

    String toString()
    {
        name
    }
}
